/*
 * TODO:
 * 1. ������Ϣ���浽��ݿ⣿��ͼ����ʽչ��
 * 2. ���������Ϣ���·���ǽ����
 * 3. ��̲鿴ʱ�����������ͷ���ǽ��Ϣ
 */

package isc.whu.defender;

import isc.whu.defender.common.Logger;
import isc.whu.defender.firewall.FirewallActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

public class DefenderMainActivity extends Activity {
	private ImageButton mBtnFireWall;
	private ImageButton mBtnNetMonitor;
	
	// for functional test
	private ImageButton mBtn1;
	private ImageButton mBtn2;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home);

		// get widget object
		mBtnFireWall = (ImageButton) findViewById(R.id.image_btn_1);
		mBtnNetMonitor = (ImageButton) findViewById(R.id.image_btn_2);
		
		// set listener
		mBtnFireWall.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Logger.write("DefenderMainActivity, start firewall button clicked.");
				Intent intent = new Intent(DefenderMainActivity.this, 
						FirewallActivity.class);
				startActivity(intent);
			}
		});
		
		mBtnNetMonitor.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Logger.write("DefenderMainActivity, start traffic monitor button clicked.");				
				
				Intent intent = new Intent(DefenderMainActivity.this, 
						isc.whu.defender.netmonitor.MonitorActivity.class);
				startActivity(intent);
				
			}
		});
		
		mBtn1 = (ImageButton) findViewById(R.id.btn_1);
		mBtn2 = (ImageButton) findViewById(R.id.btn_2);
		mBtn1.setOnClickListener(btn1ClickListener);
		mBtn2.setOnClickListener(btn2ClickListener);
	}
	
	private OnClickListener btn1ClickListener = new OnClickListener() {
		public void onClick(View v) {
			/*
			PackageManager packMgr = DefenderMainActivity.this.getPackageManager();
			try {
				Drawable appIcon = packMgr.getApplicationIcon("net.kidlogger.kidlogger");
				System.out.println(appIcon);
			} catch (NameNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			*/
		}
	};
	
	private OnClickListener btn2ClickListener = new OnClickListener() {
		public void onClick(View v) {
			Intent intent = new Intent(DefenderMainActivity.this, SettingsActivity.class);
			startActivity(intent);
		}
	};

}